"""
遍历:
    1 拿到所有key  ------->此key对应的value值
    2 拿到所有value ------>拿不到此value对应的key
    3 拿到key,也拿到value
面试题: 字典怎么遍历的?
1获取字典的keys        字典名.keys()
2或者字典的value值     字典名.values()
3 key和value都获取    字典名.items()
"""
dict2={
    "name":"张三",
    "age":10,
    "sex":"男",
    "name":"李四"
}
# 拿到所有key  dict2.keys() ---->是一个列表
# keys=dict2.keys()
# # print(list(keys))
# for a in keys:
#     print(a,dict2[a]) #dict2[a]---->拿到此key对应的value值
# print(keys)
# 拿到所有value
# for a in dict2.values():
#     print(a)

# 拿到key,也拿到value dict2.items()-->把key,vlaue变成了元组
# dict2.items()--->  [元组1,元组2,元组3]
# print(dict2.items())
# for a,b in dict2.items():  #  a,b 拆包
#     # print(a[0],a[1])
#     print(a,b)
print(dict2["name"])
